require("lualib_bundle");
__TS__SourceMapTraceBack(debug.getinfo(1).short_src, {["4"] = 5,["5"] = 5,["6"] = 5,["8"] = 5,["9"] = 23,["10"] = 24,["12"] = 26,["13"] = 26,["14"] = 27,["15"] = 28,["16"] = 29,["18"] = 26,["21"] = 32,["22"] = 23,["23"] = 35,["25"] = 36,["26"] = 36,["27"] = 37,["28"] = 38,["29"] = 39,["31"] = 36,["34"] = 42,["35"] = 35,["36"] = 46,["37"] = 47,["40"] = 51,["41"] = 52,["42"] = 53,["44"] = 55,["45"] = 56,["46"] = 58,["47"] = 59,["48"] = 60,["50"] = 62,["51"] = 63,["52"] = 65,["53"] = 66,["54"] = 67,["56"] = 69,["57"] = 70,["58"] = 46,["59"] = 74,["60"] = 75,["63"] = 78,["64"] = 80,["65"] = 81,["66"] = 82,["68"] = 84,["69"] = 85,["70"] = 86,["71"] = 88,["72"] = 89,["73"] = 90,["75"] = 92,["76"] = 93,["77"] = 94,["78"] = 96,["79"] = 97,["80"] = 98,["82"] = 100,["83"] = 101,["84"] = 102,["85"] = 74,["86"] = 5});
local ____exports = {}
____exports.default = __TS__Class()
local UnitUtil = ____exports.default
UnitUtil.name = "UnitUtil"
function UnitUtil.prototype.____constructor(self)
end
function UnitUtil.GetInventoryIndexOfItemType(unitHandle, id)
    local idint = FourCC(id)
    do
        local i = 0
        while i < 6 do
            local indexItem = UnitItemInSlot(unitHandle, i)
            if indexItem ~= nil and GetItemTypeId(indexItem) == idint then
                return i + 1
            end
            i = i + 1
        end
    end
    return 0
end
function UnitUtil.GetInventoryOfItemType(unitHandle, idint)
    do
        local i = 0
        while i < 6 do
            local indexItem = UnitItemInSlot(unitHandle, i)
            if indexItem ~= nil and GetItemTypeId(indexItem) == idint then
                return indexItem
            end
            i = i + 1
        end
    end
    return nil
end
function UnitUtil.addHeroProperty(unit, key, addNum)
    if not unit:isHero() then
        return
    end
    local baseStr = unit.strength
    if unit.solarData["UnitUtil_addHeroProperty_strength_" .. key] then
        baseStr = baseStr - unit.solarData["UnitUtil_addHeroProperty_strength_" .. key]
    end
    unit.solarData["UnitUtil_addHeroProperty_strength_" .. key] = addNum
    unit.strength = baseStr + addNum
    local baseAgi = unit.agility
    if unit.solarData["UnitUtil_addHeroProperty_agility_" .. key] then
        baseAgi = baseAgi - unit.solarData["UnitUtil_addHeroProperty_agility_" .. key]
    end
    unit.solarData["UnitUtil_addHeroProperty_agility_" .. key] = addNum
    unit.agility = baseAgi + addNum
    local baseInt = unit.intelligence
    if unit.solarData["UnitUtil_addHeroProperty_intelligence_" .. key] then
        baseInt = baseInt - unit.solarData["UnitUtil_addHeroProperty_intelligence_" .. key]
    end
    unit.solarData["UnitUtil_addHeroProperty_intelligence_" .. key] = addNum
    unit.intelligence = baseInt + addNum
end
function UnitUtil.addHeroPropertyByRate(unit, key, addRate)
    if not unit:isHero() then
        return
    end
    local addNum = 0
    local baseStr = unit.strength
    if unit.solarData["UnitUtil_addHeroPropertyByRate_strength_" .. key] then
        baseStr = baseStr - unit.solarData["UnitUtil_addHeroPropertyByRate_strength_" .. key]
    end
    addNum = baseStr * addRate
    unit.solarData["UnitUtil_addHeroPropertyByRate_strength_" .. key] = addNum
    unit.strength = baseStr + addNum
    local baseAgi = unit.agility
    if unit.solarData["UnitUtil_addHeroPropertyByRate_agility_" .. key] then
        baseAgi = baseAgi - unit.solarData["UnitUtil_addHeroPropertyByRate_agility_" .. key]
    end
    addNum = baseAgi * addRate
    unit.solarData["UnitUtil_addHeroPropertyByRate_agility_" .. key] = addNum
    unit.agility = baseAgi + addNum
    local baseInt = unit.intelligence
    if unit.solarData["UnitUtil_addHeroPropertyByRate_intelligence_" .. key] then
        baseInt = baseInt - unit.solarData["UnitUtil_addHeroPropertyByRate_intelligence_" .. key]
    end
    addNum = baseInt * addRate
    unit.solarData["UnitUtil_addHeroPropertyByRate_intelligence_" .. key] = addNum
    unit.intelligence = baseInt + addNum
end
____exports.default = UnitUtil
return ____exports
